package com.datamation.swadeshi.view;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import com.datamation.swadeshi.R;
import com.datamation.swadeshi.adapter.DamageDetAdapter;
import com.datamation.swadeshi.adapter.LoadingDetAdapter;
import com.datamation.swadeshi.adapter.LoadingItemAdapter;
import com.datamation.swadeshi.adapter.NonProductiveReasonAdapter;
import com.datamation.swadeshi.adapter.OrderDetailsAdapter;
import com.datamation.swadeshi.adapter.SetTitleAdapter;
import com.datamation.swadeshi.control.ConnectionDetector;
import com.datamation.swadeshi.control.ReferenceNum;
import com.datamation.swadeshi.control.Toast;
import com.datamation.swadeshi.control.data.FDamDetDS;
import com.datamation.swadeshi.control.data.FDamHedDS;
import com.datamation.swadeshi.control.data.FTranDetDS;
import com.datamation.swadeshi.control.data.FTranHedDS;
import com.datamation.swadeshi.control.data.ItemLocDS;
import com.datamation.swadeshi.control.data.ItemPriDS;
import com.datamation.swadeshi.control.data.ItemsDS;
import com.datamation.swadeshi.control.data.LoadingCustomDS;
import com.datamation.swadeshi.control.data.OrdDetDS;
import com.datamation.swadeshi.control.data.ReasonDS;
import com.datamation.swadeshi.control.data.SalRepDS;
import com.datamation.swadeshi.control.data.SharedPreferencesClass;
import com.datamation.swadeshi.model.FDamDet;
import com.datamation.swadeshi.model.FDamHed;
import com.datamation.swadeshi.model.FTranDet;
import com.datamation.swadeshi.model.FTranHed;
import com.datamation.swadeshi.model.ItemLoc;
import com.datamation.swadeshi.model.Items;
import com.datamation.swadeshi.model.LoadingCustom;
import com.datamation.swadeshi.model.OrdDet;
import com.datamation.swadeshi.model.Reason;

import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SearchView;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.RoundingMode;
import java.net.URL;
import java.net.URLConnection;
import java.text.DecimalFormat;

import org.json.JSONArray;
import org.json.JSONObject;

import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.SearchView.OnQueryTextListener;

public class FragmentInventoryControlDamageDetail extends Fragment implements OnClickListener{
	View view;
	private ActionBar actionBar;
	Toast  toast;
	EditText itemname,units,qoh,Case,piese,Reason;
	Button btnadd,searchitems;
	Double TotalVal,PiesValforSave,CaseValfrosave;
	LoadingCustom ItemName = null;
	LoadingCustom selectItem = null;
	ConnectionDetector Con;
	boolean connectionStatus;
	public static double RemQOH,RemQOHfinal;
	String Itemcodefrosave,ItemLocCode;
	int seqno=0,index_id=0;
	ListView lv_invent_load;
	ArrayList<FDamDet> loadlist;
	ArrayList<Reason> list2;
	public static SharedPreferences localSP;
	InputStream is = null;
	StringBuilder sb = null;
	public static final String SETTINGS = "SETTINGS";
	public static String connURLsvc="/AndroidWebServices/AndroidWebServicesRest.svc",I_ITEMCODE,I_DEALCODE,ReasonCode,I_REPCODE;
	ReferenceNum referenceNum;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.inventory_control_damagedetail, container, false);

		SetTitleAdapter objTitle =new SetTitleAdapter();
		objTitle.createCutomActionBarTitle("Damage Detail", getActivity());
		searchitems = (Button)view.findViewById(R.id.btn_item_search);
		itemname = (EditText)view.findViewById(R.id.et_item);
		units = (EditText)view.findViewById(R.id.et_unit);
		Reason = (EditText)view.findViewById(R.id._reason);
		Button ReSearch = (Button)view.findViewById(R.id.reason_search);
		qoh = (EditText)view.findViewById(R.id.et_price);
		btnadd = (Button)view.findViewById(R.id.btn_add);
		Case = (EditText)view.findViewById(R.id.et_cases);
		piese = (EditText)view.findViewById(R.id.et_pieces);
		toast = new Toast();
		seqno=0;
		connectionStatus = new ConnectionDetector(getActivity()).isConnectingToInternet();
		Con = new ConnectionDetector(getActivity());
		localSP = getActivity().getSharedPreferences(SharedPreferencesClass.SETTINGS,Context.MODE_WORLD_READABLE+Context.MODE_WORLD_WRITEABLE); 
		String sdfds = localSP.getString("URL", "");
		
		referenceNum=new  ReferenceNum(getActivity());
		FDamHedDS dsg=new FDamHedDS(getActivity());
		fatchData();
		
		final ArrayList<String> list= dsg.gettranhed(referenceNum.getCurrentRefNo(getResources().getString(R.string.DamagNumVal)));
		if(list.toString().equals("[]"))
		{
			
			toast.createToastMessage("Please select Item", getActivity());
			getActivity().getActionBar().setSelectedNavigationItem(0);
			
		}
		
		FDamHedDS hedDS =new FDamHedDS(getActivity());
		ArrayList<FDamHed> getTranHed = hedDS.getAllActiveFtranHed(referenceNum.getCurrentRefNo(getResources().getString(R.string.DamagNumVal)));
		MainActivity activity =(MainActivity) getActivity();
		
		for (FDamHed ordHed : getTranHed) 
		{
			
			activity.selectedFdamHed=ordHed;
		}

		
		searchitems.setOnClickListener(this);

		btnadd.setOnClickListener(this);
	
		
		
		Case.addTextChangedListener(new TextWatcher() 
		{
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) 
			{
				casesCalc();
				// TODO Auto-generated method stub
			}
			
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after){
				// TODO Auto-generated method stub
			}
			
			@Override
			public void afterTextChanged(Editable s){
				// TODO Auto-generated method stub
			}
		});
		
		piese.addTextChangedListener(new TextWatcher() {
			
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				// TODO Auto-generated method stub
				piecesCalc();
			}
			
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}
			
			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				
			}
		});
		
		lv_invent_load.setOnItemLongClickListener(new OnItemLongClickListener() {

			@Override
			public boolean onItemLongClick(AdapterView<?> parent, View view,
					int position, long id) {
				// TODO Auto-generated method stub
				FDamDet ftrnd = loadlist.get(position);
				deleteOrderDialog(getActivity(), "DETAIL",ftrnd.getFDAMDET_ID());
				
				return false;
			}
		});
		
		ReSearch.setOnClickListener(new View.OnClickListener() 
		{
			
			@Override
			public void onClick(View v) 
			{
				// TODO Auto-generated method stub
				switch (v.getId()) 
				{
				case R.id.reason_search:
					ReasonDetailsDialogbox("");
					break;
				
				default:
					break;
				}
				
			}
		});
		
		
		lv_invent_load.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view2,int position, long id) 
			{
				
				
				clearTextFields();
				
			searchitems.setClickable(false);	
			btnadd.setText("Update");
			
			FDamDet ftrndet = loadlist.get(position);
			
			
			index_id= Integer.parseInt(ftrndet.getFDAMDET_ID());
			ItemName = new LoadingCustom();
			ItemName.setSTOCK_LOADING_ITEMCODE(ftrndet.getFDAMDET_ITEMCODE());
			LoadingCustomDS dst =new LoadingCustomDS(getActivity());
			itemname.setText(dst.getItemNameByCode(ftrndet.getFDAMDET_ITEMCODE()));
			
			units.setText(dst.getItemUnitsByCode(ftrndet.getFDAMDET_ITEMCODE()));
			
			//FTranHedDS HedDS = new FTranHedDS(getActivity());
			//String ff = HedDS.getLocCodebyRefNo(referenceNum.getCurrentRefNo(getResources().getString(R.string.LodNumVal)));
			
			//qoh.setText(dst.getItemQohByCodeUnLoad(ftrndet.getFTRANDET_ITEMCODE(), HedDS.getLocCodebyRefNo(referenceNum.getCurrentRefNo(getResources().getString(R.string.LodNumVal)))));
		//	Reason.setText(parent.getItemAtPosition(position).toString().split("-:-")[0]);
			Reason.setText(ftrndet.getFDAMDET_REANAME());
			RemQOH =Double.parseDouble(dst.getItemQohByCode(ftrndet.getFDAMDET_ITEMCODE()));
			piese.setText(ftrndet.getFDAMDET_PICEQTY());
			Case.setText(ftrndet.getFDAMDET_CASEQTY());
	
			}
		});
		
		return view;
	}
	
	
	
	
	
	private void piecesCalc()
	{
		if(!(units.length() == 0)){	
		   	if(!(piese.length() == 0)){
		   		if(Case.length() == 0){
		    			Case.setText("0");
			    		}
			    		TotalVal=(Double.parseDouble(Case.getText().toString()) * Double.parseDouble(units.getText().toString())) +  Double.parseDouble(piese.getText().toString());
		    		}else{
		    			if(Case.length() == 0){
		    				Case.setText("0");
			    		}
			    		TotalVal=(Double.parseDouble(Case.getText().toString()) * Double.parseDouble(units.getText().toString())) + 0;
		    		}
		    	
		    	if(TotalVal<=RemQOH){
					RemQOHfinal = RemQOH-TotalVal;
					PiesValforSave = TotalVal%Double.parseDouble(units.getText().toString());
					CaseValfrosave =Math.floor(TotalVal/Double.parseDouble(units.getText().toString())+0d);
					
					
					qoh.setText(String.valueOf(RemQOHfinal ));
					
				}
				else{
					toast.createToastMessage("You Exceed QOH", getActivity());
					piese.setText("0");
				}
		    		
		    	}

	}
	private void casesCalc(){
    	if(!(units.length() == 0)){	
    		if(!(Case.length() == 0)){
     			if(piese.length() == 0){
    				piese.setText("0");
    			}
    		
    			TotalVal=(Double.parseDouble(Case.getText().toString()) * Double.parseDouble(units.getText().toString())) +  Double.parseDouble(piese.getText().toString());
    		}else{
    			if(piese.length() == 0){
    				piese.setText("0");
	    		}
     			TotalVal=( 0 * Double.parseDouble(units.getText().toString())) +  Double.parseDouble(piese.getText().toString());
    		}
    		
    		if(TotalVal<=RemQOH)
			{
				RemQOHfinal = RemQOH-TotalVal;
				
				PiesValforSave = TotalVal%Double.parseDouble(units.getText().toString());
				CaseValfrosave =Math.floor(TotalVal/Double.parseDouble(units.getText().toString())+0d);
				
				qoh.setText(String.valueOf(RemQOHfinal ));
			}
			else 
			{
				toast.createToastMessage("You Exceed QOH", getActivity());
				Case.setText("0");
			}
    		
    	}
	}
	ArrayList<LoadingCustom> list=null;
	public void loctDetailsDialogbox()
	{		
		final Dialog dialog = new Dialog(getActivity());
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		dialog.setContentView(R.layout.inventory_control_searchitems);
		final SearchView search = (SearchView) dialog.findViewById(R.id.et_search);
		final ListView locList=(ListView) dialog.findViewById(R.id.lv_product_items); 
		dialog.setCancelable(true);
		
		ArrayList<FDamHed> ftrnhedlist=new ArrayList<FDamHed>();
		final MainActivity activity =(MainActivity) getActivity();
		ftrnhedlist.add(activity.selectedFdamHed);
		
		LoadingCustomDS dsg=new LoadingCustomDS(getActivity());
		list= dsg.getAllItemLoading("",activity.selectedFdamHed.getFDAMHED_REFNO());
		
		locList.clearTextFilter();
		locList.setAdapter(new LoadingItemAdapter(getActivity(),list));
		locList.setOnItemClickListener(new OnItemClickListener()
		{
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) 
			{
				ItemName =list.get(position); 
				SalRepDS repDS=new SalRepDS(activity);

				//getSaleRepDetails
				I_ITEMCODE = ItemName.getSTOCK_LOADING_ITEMCODE().toString();
				I_DEALCODE = repDS.getDealCode().toString();
				I_REPCODE  = repDS.getCurrentRepCode();
				if(connectionStatus==true){
					
			//	new GetLoadingUpdate().execute();
				}
				else 
				{
					getActivity().getActionBar().setSelectedNavigationItem(0);
					Con.showSettingsAlert();
				}
				LoadingCustomDS dst =new LoadingCustomDS(getActivity());
				itemname.setText(ItemName.getSTOCK_LOADING_ITEMNAME());
				units.setText(ItemName.getSTOCK_LOADING_ITEMNOUCASE());
				qoh.setText(dst.getItemQohByCodeUnLoad(ItemName.getSTOCK_LOADING_ITEMCODE(), "MS"));
				RemQOH = Double.parseDouble(dst.getItemQohByCodeUnLoad(ItemName.getSTOCK_LOADING_ITEMCODE(), "MS"));
				Itemcodefrosave  =ItemName.getSTOCK_LOADING_ITEMCODE();
				ItemLocCode = ItemName.getSTOCK_LOADING_ITEMLOCCODE();
				

				
				
				dialog.dismiss();
			}
		});
		
			
		search.setOnQueryTextListener(new OnQueryTextListener() 
		{
			@Override
			public boolean onQueryTextSubmit(String query) 
			{
				return false;
			}
			
			@Override
			public boolean onQueryTextChange(String newText) 
			{
				list.clear();
				LoadingCustomDS locds =new LoadingCustomDS(getActivity());
				locList.clearTextFilter();
				list= locds.getAllItemLoading(newText,activity.selectedFdamHed.getFDAMHED_REFNO());
				locList.setAdapter(new LoadingItemAdapter(getActivity(),list));
				return false;
			}
		});				
		dialog.show();
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btn_add:
			btnadd.setText("Add");
			searchitems.setClickable(true);
			if (TotalVal!=null){ 
				if(Case.length()>0 && piese.length()>0){
					if(TotalVal!=0)
					{
						
						FDamDet ftranDet=new FDamDet();
						FDamDetDS detDS=new FDamDetDS(getActivity());
						
						ArrayList<FDamDet> FtrnDetlist=new ArrayList<FDamDet>();
						
						FDamHed fdamhed=new FDamHed();
						FDamHedDS ftrnhed =new FDamHedDS(getActivity());
						SalRepDS repDS=new SalRepDS(getActivity());
						ArrayList<FDamHed> ftrnhedlist=new ArrayList<FDamHed>();
						MainActivity activity =(MainActivity) getActivity();
						
						ftrnhedlist.add(activity.selectedFdamHed);
						
						if(ftrnhed.createOrUpdateFTranHed(ftrnhedlist)>0)
						{
							
							ItemPriDS LOCF =new ItemPriDS(getActivity());
							
							
							DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
							Date date = new Date();
							seqno++;
							ftranDet.setFDAMDET_ID(index_id+"");
							//int as = index_id+1;
							ftranDet.setFDAMDET_REFNO(activity.selectedFdamHed.getFDAMHED_REFNO());
							ftranDet.setFDAMDET_TXNDATE(dateFormat.format(date));
							ftranDet.setFDAMDET_LOCCODE("DS");
							ftranDet.setFDAMDET_TXNTYPE("42");
							ftranDet.setFDAMDET_SEQNO(seqno+"");
							ftranDet.setFDAMDET_ITEMCODE(ItemName.getSTOCK_LOADING_ITEMCODE());
							ftranDet.setFDAMDET_QTY(TotalVal.toString());
							
							String AmountDet="";
							DecimalFormat format = new DecimalFormat("########.##");
							Double totalAmountVal = (Double.parseDouble(LOCF.getProductPriceByCode(ItemName.getSTOCK_LOADING_ITEMCODE()))/Double.parseDouble(units.getText().toString())*Double.parseDouble(TotalVal.toString()));
						//	AmountDet = (String.format("%,.2f",totalAmountVal));
							ftranDet.setFDAMDET_AMT(format.format(totalAmountVal));
							ftranDet.setFDAMDET_REANAME(Reason.getText()+"");
							ftranDet.setFDAMDET_REACODE(ReasonCode);
						//	ftranDet.setFTRANDET_AMT(String.valueOf(Double.parseDouble(LOCF.getProductPriceByCode(ItemName.getSTOCK_LOADING_ITEMCODE()))/Double.parseDouble(units.getText().toString())*Double.parseDouble(TotalVal.toString())));
							ftranDet.setFDAMDET_CASEQTY(CaseValfrosave.toString());
							ftranDet.setFDAMDET_PICEQTY(PiesValforSave.toString());
							ftranDet.setREMQTY(new Double(RemQOHfinal).toString());
							
							
							FtrnDetlist.add(ftranDet);
							
							if(detDS.createOrUpdateftrandet(FtrnDetlist) > 0)
							{
								
								clearTextFields();
								toast.createToastMessage("Added successfully", getActivity());
								//actionBar.removeAllTabs();
								
								fatchData();
								
							}
						}
					}
				}
			}

			
			break;

			case R.id.btn_item_search:
				loctDetailsDialogbox();	
			
		default:
			break;
		}
	}
	public void fatchData()
	{
		try {
			MainActivity activity =(MainActivity) getActivity();
			lv_invent_load = (ListView) view.findViewById(R.id.lv_loading_det);
			lv_invent_load.clearTextFilter();
			FDamDetDS detDS = new FDamDetDS(getActivity());
			loadlist = detDS.getAllloadDetails(referenceNum.getCurrentRefNo(getResources().getString(R.string.DamagNumVal)));
			
			lv_invent_load.setAdapter(new DamageDetAdapter(getActivity(), loadlist));
		}catch (NullPointerException e){
			Log.v("Damage Error", e.toString());
		}
	}
	
	
	public void clearTextFields() 
	{
		index_id= 0;
		Case.setText("0");
		piese.setText("0");
		units.setText("0");
		qoh.setText("0");
		itemname.setText("");
		
	}
	
	private void deleteOrderDialog(final Context context,String title, final String recordId){

		AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
		//alertDialogBuilder.setTitle(title);
		alertDialogBuilder.setMessage("Are you sure you want to delete this entry?");
		alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
		alertDialogBuilder
				.setCancelable(false)
				.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
							
								int count =new FDamDetDS(context).deleteOrdDetByID(recordId);					
								if(count >0){
									//android.widget.Toast.makeText(context, "Deleted successfully",android.widget.Toast.LENGTH_LONG).show();
									toast.createToastMessage("Deleted successfully", getActivity());
									fatchData();
									clearTextFields();
								}
							}
						})
				.setNegativeButton("No",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog,	int id) {
								dialog.cancel();
								
								
							}
						});
		
		AlertDialog alertD = alertDialogBuilder.create();

		alertD.show();
	}
	
	public void ReasonDetailsDialogbox(String searchword)
	{		
		final Dialog dialog = new Dialog(getActivity());
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		dialog.setContentView(R.layout.nonprod_retailer_search);
		final SearchView search = (SearchView) dialog.findViewById(R.id.rt_search);
		final ListView locList=(ListView) dialog.findViewById(R.id.rt_product_items); 
		dialog.setCancelable(true);
		
		ReasonDS dsg=new ReasonDS(getActivity());
		list2= dsg.getAllReasons("RT01");
	   	locList.clearTextFilter();
		locList.setAdapter(new NonProductiveReasonAdapter(getActivity(),list2));
		locList.setOnItemClickListener(new OnItemClickListener()
		{

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) 
			{
				Reason.setText(list2.get(position).getFREASON_NAME());
				ReasonCode = list2.get(position).getFREASON_CODE();
			
				dialog.dismiss();
			}
		});
		
			
		search.setOnQueryTextListener(new OnQueryTextListener() 
		{
			
			@Override
			public boolean onQueryTextSubmit(String query) 
			{
				return false;
			}
			
			@Override
			public boolean onQueryTextChange(String newText) 
			{
				ReasonDS locds =new ReasonDS(getActivity());
				locList.clearTextFilter();
				list2= locds.getDebDetails(newText);
				locList.setAdapter(new NonProductiveReasonAdapter(getActivity(),list2));
				return false;
			}
		});				
		dialog.show();
	}
	
	
	private class GetLoadingUpdate extends AsyncTask<Void, Void, String> {

		@Override
		protected String doInBackground(Void... params) {
			// TODO Auto-generated method stub
			
			//try {
				
			String sQoh = "0";
				try {
				FTranHedDS hedDS =new FTranHedDS(getActivity());
				ArrayList<FTranHed> getTranHed = hedDS.getAllActiveFtranHed(referenceNum.getCurrentRefNo(getResources().getString(R.string.DamagNumVal)));
				MainActivity activity =(MainActivity) getActivity();
				
				for (FTranHed ordHed : getTranHed) 
				{
					
					activity.selectFtranHed=ordHed;
				}
			
				ItemLocDS loc = new ItemLocDS(getActivity());
				ItemLoc sav=new ItemLoc();
				ArrayList<ItemLoc> itemloclist=new ArrayList<ItemLoc>();
				//checkNetwork();
				URL jsonItemstock = new URL("Http://"+localSP.getString("URL", "")+"/AndroidWebServices/AndroidWebServicesRest.svc/OnlineItemStock/mobile123/DSPL_CONSOLE/"+I_ITEMCODE+"/"+I_DEALCODE);

				URLConnection jc = jsonItemstock.openConnection();
				BufferedReader readerItemstock = new BufferedReader(new InputStreamReader(jc.getInputStream()));
				String line = readerItemstock.readLine();
				JSONObject jsonResponse = new JSONObject(line);
				JSONArray jsonArray = jsonResponse.getJSONArray("OnlineItemStockResult");
	
				for (int i = 0; i < jsonArray.length(); i++)
				{
					final JSONObject jObject = (JSONObject) jsonArray.get(i);
					sav.setFITEMLOC_ITEM_CODE(I_ITEMCODE);
					sav.setFITEMLOC_LOC_CODE("MS");
					sav.setFITEMLOC_QOH(jObject.getString("QOH"));
					itemloclist.add(sav);
					if(loc.createOrUpdateItemLoc(itemloclist) > 0)
					{
						//
						//String sd = jObject.getString("QOH");
						sQoh=jObject.getString("QOH");
					
						RemQOH = Double.parseDouble(jObject.getString("QOH"));
			
					}else 
					{
						toast.createToastMessage("Online Validate Fail", getActivity());
						itemname.setText("");
						units.setText("0");
					}
				}
				readerItemstock.close();
			
			} catch (Exception e) 
			{
				//toast.createToastMessage("Connection Error" + e.toString(), getActivity());
				Log.v("Valiodation Error", e.toString());
			
			}
			
			return sQoh;
		}

		@Override
		protected void onPostExecute(String result) {
			// TODO Auto-generated method stub
			
			qoh.setText(result.toString());
			toast.createToastMessage("Online Validate sucess", getActivity());
			super.onPostExecute(result);
		}
		
		
	}
}

